package c.c.b.a.b.a.i;

import c.c.b.a.b.a.e;
import c.c.b.a.b.a0;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import javax.net.ssl.SSLSocket;

/* compiled from: JdkWithJettyBootPlatform */
public class c extends e {
    public final Method c;
    public final Method d;
    public final Method e;
    public final Class<?> f;
    public final Class<?> g;

    /* compiled from: JdkWithJettyBootPlatform */
    public static class a implements InvocationHandler {
        public final List<String> a;
        public boolean b;
        public String c;

        public a(List<String> list) {
            this.a = list;
        }

        public Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
            String name = method.getName();
            Class returnType = method.getReturnType();
            if (objArr == null) {
                objArr = e.b;
            }
            if (name.equals("supports") && Boolean.TYPE == returnType) {
                return Boolean.TRUE;
            }
            if (name.equals("unsupported") && Void.TYPE == returnType) {
                this.b = true;
                return null;
            } else if (name.equals("protocols") && objArr.length == 0) {
                return this.a;
            } else {
                if ((name.equals("selectProtocol") || name.equals("select")) && String.class == returnType && objArr.length == 1 && (objArr[0] instanceof List)) {
                    List list = (List) objArr[0];
                    int size = list.size();
                    for (int i = 0; i < size; i++) {
                        if (this.a.contains(list.get(i))) {
                            name = (String) list.get(i);
                            this.c = name;
                            return name;
                        }
                    }
                    name = (String) this.a.get(0);
                    this.c = name;
                    return name;
                } else if ((!name.equals("protocolSelected") && !name.equals("selected")) || objArr.length != 1) {
                    return method.invoke(this, objArr);
                } else {
                    this.c = (String) objArr[0];
                    return null;
                }
            }
        }
    }

    public c(Method method, Method method2, Method method3, Class<?> cls, Class<?> cls2) {
        this.c = method;
        this.d = method2;
        this.e = method3;
        this.f = cls;
        this.g = cls2;
    }

    public String d(SSLSocket sSLSocket) {
        try {
            Object[] objArr = new Object[]{sSLSocket};
            String str = null;
            a aVar = (a) Proxy.getInvocationHandler(this.d.invoke(null, objArr));
            boolean z = aVar.b;
            if (z || aVar.c != null) {
                if (!z) {
                    str = aVar.c;
                }
                return str;
            }
            e.a.g(4, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", null);
            return null;
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw e.f("unable to get selected protocol", e);
        }
    }

    public void j(SSLSocket sSLSocket, String str, List<a0> list) {
        List e = e.e(list);
        try {
            Object newProxyInstance = Proxy.newProxyInstance(e.class.getClassLoader(), new Class[]{this.f, this.g}, new a(e));
            this.c.invoke(null, new Object[]{sSLSocket, newProxyInstance});
        } catch (IllegalAccessException | InvocationTargetException e2) {
            throw e.f("unable to set alpn", e2);
        }
    }

    public void l(SSLSocket sSLSocket) {
        try {
            this.e.invoke(null, new Object[]{sSLSocket});
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw e.f("unable to remove alpn", e);
        }
    }
}
